const Router = require("@koa/router");
const swaggerJSDoc = require('swagger-jsdoc');
const path = require('path');
const router = new Router();
const swaggerDefinition = {
    openapi: '3.0.1',
    info: {
        title: '糖尿病项目接口文档',
        version: '1.0.0',
        description: 'API文档',
    },
    host: 'localhost:8081',
    basePath: '/', // Base path (optional)
    components: {
        securitySchemes: {
          bearerAuth: {
            type: 'http',
            scheme: 'bearer',
            bearerFormat: 'JWT',
          }
        }
      }
};
const options = {
    swaggerDefinition,
    apis: [path.join(__dirname, '../routes/*.js')], //配置路由router文件的位置
};
const swaggerSpec = swaggerJSDoc(options)
// 通过路由获取生成的注解文件
router.get('/swagger.json', async function (ctx) {
    ctx.set('Content-Type', 'application/json');
    ctx.body = swaggerSpec;
})
module.exports = router
